-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
added rkf45 method #10438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added rkf45 method #10438
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed whitespace
removed some whitespace |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated rkf45.py as per suggestions
updated rkf45.py as per suggestions |
maths/rkf45.py
Outdated
#excact value of y[1] is tan(0.2) = 0.2027100355086 | ||
>>> def f(x,y): | ||
... return 1+y**2 | ||
>>> y=rkf45(f,0,0,0.2,1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> y=rkf45(f,0,0,0.2,1) | |
>>> y=rkf45(f, 0, 0, 0.2, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved Code Quality
maths/rkf45.py
Outdated
>>> y=runge_futta_fehlberg_45(f, 0, 0, 0.2, 1) | ||
>>> y[1] | ||
0.2027100937470787 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need more than one test. What happens if x_initial
is set to 5, -5, 5.5?
What happens if step_size
is zero or negative?
What happens if x_final
is zero or negative?
What happens if ode
is 5
instead of being a function?
Let's have a test that raises a RangeError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Condition on x_initial and x_final is that x_final should be greater than x_initial. They can be zero , negative or positive.
- Added exception for step_size as it should be positive.
- ode can be a constant function or a function of x and/or y.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more test cases and exception.
maths/rkf45.py
Outdated
>>> y=runge_futta_fehlberg_45(f, 0, 0, 0.2, 1) | ||
>>> y[1] | ||
0.2027100937470787 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Condition on x_initial and x_final is that x_final should be greater than x_initial. They can be zero , negative or positive.
- Added exception for step_size as it should be positive.
- ode can be a constant function or a function of x and/or y.
Added more test cases and exception. |
for more information, see https://pre-commit.ci
Nice one! It is great that you deal with invalid input. |
@cclauss : Please add hacktoberfest-accepted label so that it can be accepted in hacktoberfest. |
* added rkf45 method * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated rkf45.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated rkf45.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update rkf45.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update rkf45.py with suggestions * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Improved Code Quality rkf45.py * Added more test cases and exception rkf45.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update rkf45.py * corrected some spellings. rkf45.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update rkf45.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update rkf45.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <[email protected]>
Add an algorithm (rkf45) to TheAlgorithms / Python/maths